
SNFMerchantOptions = { ["DebugLevel"] = 0, ["Status"] = "On", ["version"] = "0.0",};

local tMerchantOptions_Defaults = {
	["0.0"] = {
		["DebugLevel"] = 0,
		["version"] = "0.0",
	},

};

function SNFCheckDefaults()
	if not SNFMerchantOptions then
		SNFMerchantOptions = tMerchantOptions_Defaults[SNFGetMerchantVersion()]
		SMDEBUG(1, "Options initialized to default values")
	end
end

local function ParseEditCommand(cmd)

	return false;
end

local function ParseListCommand(cmd)

	return false
end


local function ParseSetCommand(cmd)
	local str = strmatch(cmd, "set (.*)")

	if (str ~= nil) then
		local sub = strmatch(str, "debug ([0-9]*)")
		if sub then
			d = tonumber(sub)
			if d and d <= 4 and d >= 0 then
				SNFMerchantOptions["DebugLevel"] = d
				SMDEBUG(0, "SNFMerchant: DebugLevel set to "..d);
				return true
			end
		end
	end
	return false
end

function SNFMerchant_Options(arg1,...)

	if not arg1 or arg1 == "" or arg1 == "help" then
		SMDEBUG(0, "Usage: /SM on|off - does nothing :)")
		return
	end
	if arg1 == "off" and not (SNFMerchantOptions["Status"] == "off") then
		SNFMerchant_Unregister()
		SMDEBUG(0, "Turned off");
		return
	end
	if arg1 == "on" and not (SNFMerchantOptions["Status"] == "on") then
		SNFMerchant_Register()
		SMDEBUG(0, "Turned on");
		return
	end


	if arg1 == "q" then
		SNFAuc:GetAuctioningGlyphs()
		return
	end
	if arg1 == "a" then
		SNFAuc:AnalyzeQueryCounts()
		return
	end

	if arg1 == "s" then
		SMSkills:ListSkills()
		return
	end

	if arg1 == "sv" then
		SMItemSource:ScanVendor()
		return
	end

	if arg1 == "sc" then
		SMItemSource:ScanCraft()
		return
	end

	local str = strmatch(arg1, "^c (.*)$")
	if str then
		SMItemSource:CraftDetails(str)
		--SMSkills:CraftDetails(str)
		return
	end




	if ParseListCommand(arg1) then return end

	if ParseSetCommand(arg1) then return end

	if ParseEditCommand(arg1) then return end

	if arg1 == "new" then
		--document what's new in this version
	end
	if arg1 == "ta" then
	end

	SMDEBUG(0,"Command not recognized ("..arg1..")")
end

function SNFMGetDebugLevel()
	return SNFMerchantOptions["DebugLevel"] or 0;
end
